package org.redis.cluster.config;

import java.io.Serializable;

public class ClientConfig implements Serializable {
	
	private String id;
	private String client;
	private String host;
	private Integer port;
	private Integer connection;
	private Integer timeout;
	
	private transient ClientInfo info;
	
	public ClientConfig() {
		this.id=initId();
	}

	protected String initId() {
		return IdGenerator.getId();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getClient() {
		return client;
	}

	public void setClient(String client) {
		this.client = client;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public Integer getConnection() {
		return connection;
	}

	public void setConnection(Integer connection) {
		this.connection = connection;
	}

	public Integer getTimeout() {
		return timeout;
	}

	public void setTimeout(Integer timeout) {
		this.timeout = timeout;
	}

	public ClientInfo getInfo() {
		return info;
	}

	public void setInfo(ClientInfo info) {
		this.info = info;
	}
	
	@Override
	public int hashCode() {
		return getId().hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof ClientConfig)) {
			return false;
		}
		
		return ((ClientConfig)obj).getId().equals(getId());
	}

	@Override
	public String toString() {
		return String.format("{id:%s,host:%s,port:%s,connection:%s,timeout:%s,info:%s}", 
				getId(),getHost(),getPort(),getConnection(),getTimeout(),getInfo());
	}
}